import os
import csv

project_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = project_dir.replace('scripts','')
# project_dir = '/'.join(project_dir.split('/')[:-1])
# project_dir = '\\'.join(project_dir.split('\\')[:-1])

with open(os.path.join(project_dir,'data/train_drcat_01.csv'),'r',encoding='utf-8') as fr:
    lines = csv.reader(fr)
    count = 0
    with open(os.path.join(project_dir,'data/train_drcat_01_sample100.csv'),'w',encoding='utf-8',newline='') as fw:
        writer = csv.writer(fw)
        header = next(lines)
        writer.writerow(header)
        for line in lines:
            writer.writerow(line)
            count += 1
            if count > 100:
                break

with open(os.path.join(project_dir,'data/train_drcat_01_sample100.csv'),'r',encoding='utf-8') as fr:
    lines = csv.reader(fr)
    header = next(lines)
    for line in lines:
        print(line)